import requests
from InfoGetter import tools
import json
import time


def database_init(cur, log):
    """
    TODO 初始化数据库，建立表格
    :param cur:
    :param log:
    :return:
    """
    # log.logger.info("开始初始化<高校录取数据-数据表>")
    # cur.execute("DROP TABLE IF EXISTS %s" % 'specialties_admissions_data')
    # cur.execute("""CREATE TABLE specialties_admissions_data(
    #     categoryId VARCHAR(10),
    #     collegeName VARCHAR(20) COMMENT '大学名称',
    #     categoryName VARCHAR(20) COMMENT '批次名称',
    #     subject VARCHAR(10) COMMENT '文科',
    #     historyYear VARCHAR(10) COMMENT '年份',
    #     specialtyName VARCHAR(20) COMMENT '专业名称',
    #     minGradeDiff VARCHAR(10) COMMENT '实录分线差(VIP)',
    #     minGradeRank VARCHAR(10) COMMENT '实录分位次(VIP)',
    #     avgGradeDiff VARCHAR(10) COMMENT '平均分线差(VIP)',
    #     avgGradeRank VARCHAR(10) COMMENT '平均分位次(VIP)',
    #     positionAvgGrade VARCHAR(10) COMMENT '成都市一诊成绩同位平均分(VIP)',
    #     positionMinGrade VARCHAR(10) COMMENT '成都市一诊成绩同位实录分(VIP)',
    #     historyCollegeId VARCHAR(20),
    #     specialtyId VARCHAR(20),
    #     specialtyType VARCHAR(10),
    #     displayName VARCHAR(20) COMMENT '类型',
    #     province VARCHAR(10),
    #     provinceName VARCHAR(10) COMMENT '省份',
    #     categoryShortName VARCHAR(20) COMMENT '批次缩写',
    #     scoreLevelName VARCHAR(20) COMMENT '批次等级',
    #     logo VARCHAR(255) COMMENT 'logo地址',
    #     avgGrade VARCHAR(10) COMMENT '平均分',
    #     minGrade VARCHAR(10) COMMENT '实录分'
    #                             )""")
    # log.logger.info("<专业录取数据-数据表>初始化完成")
    # log.logger.info("*"*100 + "\n")


def get_player_links(conn, cur, cfg, log):
    """
    TODO 获取球员详情页url
    :param conn:
    :param cur:
    :param cfg:
    :param log:
    :return:
    """

    return {'code': 1, 'msg': '全部数据获取完成'}


def parse_player_data(conn, cur, json_data, year, batch, log, sch_name, class_type):
    """
    解析球员数据，保存至某容器以供后续操作

    """

    pass


def store_in_db(conn, cur, lst):
    """
    保存数据至数据库
    :param conn:
    :param cur:
    :param lst:
    :return:
    """

    command = "INSERT INTO XXX VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s," \
              " %s, %s, %s, %s, %s, %s, %s, %s, %s)"
    cur.execute(
         command, lst

    )
    conn.commit()




